﻿Public Class F_ChuyenBan

    Private Sub gvBanan_CellContentClick(sender As Object, e As DataGridViewCellEventArgs)

    End Sub
    dim b As New DTOBanAn
    Public Sub receiver(ByVal ban As DTOBanAn)
        b = ban
        txtTenBan.Text = b.TenBan
    End Sub
    Private Sub gvBanan_CellContentClick_1(sender As Object, e As DataGridViewCellEventArgs)

    End Sub
    Sub LoadBanAnTrong()
        Dim sql As String = "select * from Banan where MaTT=1"
        gvBan.DataSource = DataProvider.LoadTable(sql)
    End Sub
    Private Sub F_ChuyenBan_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        LoadBanAnTrong()
    End Sub

    Private Sub gvBan_SelectionChanged(sender As Object, e As EventArgs) Handles gvBan.SelectionChanged
        Dim maban As Integer = gvBan.CurrentRow.Cells("MaBan").Value

    End Sub

    Private Sub btnChon_Click(sender As Object, e As EventArgs) Handles btnChon.Click
        Dim maban As Integer = gvBan.CurrentRow.Cells("MaBan").Value
        'set lai tinh trang
        Dim sqlA As String = "update BanAn set maTT = 1 where maBAn = " & b.MaBan
        Dim sqlB As String = "update BanAn set maTT = 2 where maBAn = " & maban
        DataProvider.ExecuteNonQuery(sqlA)
        DataProvider.ExecuteNonQuery(sqlB)
        'set lai hoadon
        Dim sqlHoaDon As String = String.Format("update HOaDOn set MaBan ={0} where Tinhtrang = 0 and maBAn = {1}", maban, b.MaBan)
        DataProvider.ExecuteNonQuery(sqlHoaDon)
        me.Close
    End Sub
End Class